<h3>Comments</h3>
{% if comments %}
    {% for comment in comments %}
        <div id="comment-id-{{ comment.id }}" class="comment{% ifequal comment.id new_comment_id %} new{% endifequal %}">
            <div class="content">{{ comment.message|safe|linebreaks }}</div>
            <div class="meta">Comment by 
                <span class="author">
                        {% if comment.website %}<a href="{{ comment.website }}">{{ comment.name }}</a>{% else %}{{ comment.name }}{% endif %}
                </span> - 
                {{ comment.date|date:date_format }} at {{ comment.date|date:time_format }}
            </div>
        </div>
    {% endfor %}

{% else %}
    <p>There are no comments for this post.</p>
{% endif %}
            
{% if allowed %}
    <!-- comment submission form -->
    {% if post.comments_enabled %}
        <h3>Leave a Comment</h3>
        <p>You can use basic HTML tags: i, em, strong, b, u, a, pre</p>
        <p><em>All fields are required.</em></p>
        <form id="commentForm" action="" method="post">
            <table>
                {% for field in comment_form %}
                    <tr>
                        <td>{{ field.label_tag }}:</td>
                        <td{% if field.errors %} class="error"{% endif %}>
                            {% if field.errors %}{{ field.errors }}{% endif %}
                            {{ field }} {{ field.help_text }}
                        </td>
                    </tr>
                {% endfor %}
                <tr>
                    <td>&nbsp;</td>
                    <td>
                        <script type="text/javascript" src="http://api.recaptcha.net/js/recaptcha_ajax.js"></script>
                        {% if captcha_error %}
                            <ul class="errorlist"><li>Captcha does not match.</li></ul>
                        {% endif %}
                        <div id="recaptcha"></div>
                        <script type="text/javascript">
                        Recaptcha.create("{{ recaptcha_key }}",
                        "recaptcha", {{ RECAPTCHA_SETTINGS|safe }});
                        </script>
                        <noscript>
                           <iframe src="http://api.recaptcha.net/noscript?k=<your_public_key>"
                               height="300" width="500" frameborder="0"></iframe><br>
                           <textarea name="recaptcha_challenge_field" rows="3" cols="40">
                           </textarea>
                           <input type="hidden" name="recaptcha_response_field" 
                               value="manual_challenge">
                        </noscript>
                    </td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td><input type="submit" name="_comment" value="Submit" /></td>
                </tr>
            </table>
            <div class="loading"></div>
        </form>
    {% else %}
        <p><em>Comments are closed for this post.</em></p>
    {% endif %}
{% else %}
    <p><em>Your IP ({{ user_ip }}) has been banned from commenting on this blog.</em></p>
{% endif %}
